#include "SystemTrayIcon.hpp"

SystemTrayIcon::SystemTrayIcon(HWND window, int iconId)
{
  ZeroMemory(&m_iconData, sizeof(m_iconData));
  m_iconData.cbSize = sizeof(m_iconData);
  m_iconData.hWnd   = window;
  m_iconData.uID    = iconId;
}

bool SystemTrayIcon::Create(HICON icon, const TCHAR* tooltip)
{
  m_iconData.uFlags           = NIF_ICON | NIF_MESSAGE | NIF_TIP;
  m_iconData.uCallbackMessage = WM_SYSTEMTRAY;
  m_iconData.hIcon            = icon;

  lstrcpy(m_iconData.szTip, tooltip);
  return (Shell_NotifyIcon(NIM_ADD, &m_iconData) != 0);
}

bool SystemTrayIcon::ChangeIcon(HICON icon)
{
  m_iconData.uFlags  = NIF_ICON;
  m_iconData.hIcon   = icon;

  return (Shell_NotifyIcon(NIM_MODIFY, &m_iconData) != 0);
}

bool SystemTrayIcon::Destroy()
{
	return (Shell_NotifyIcon(NIM_DELETE, &m_iconData) != 0);
}